package com.gaga.common.enums;

import java.util.Locale;

public enum ScriptItemFileType {
    TXT("txt", "文本"),
    WAV("wav", "音频"),
    MP3("mp3", "音频"),
    MP4("mp4", "视频"),
    FOLDER("folder", "文件夹"),
    ;

    private final String code;
    private final String info;

    ScriptItemFileType(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public String getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }

    public static ScriptItemFileType getScriptItemTypeByCode(String code) {
        for (ScriptItemFileType scriptType : ScriptItemFileType.values()) {
            if (code.toLowerCase(Locale.ROOT).endsWith(scriptType.getCode().toLowerCase(Locale.ROOT))) {
                return scriptType;
            }
        }
        return null;
    }
}
